<?php

namespace fanletter\model;

use fanletter\manager\NewsletterManager;

class Newsletter
{
	private $id;
	private $title;
	private $date;
	private $sent;
	private $designId;
	private $content;
	
	public function __construct($id = 0, $title = '', \DateTime $date = NULL, $sent = FALSE, $designId = '')
	{
		if ($date === NULL)
		{
			$date =  new \DateTime();
		}
		$this->id = intval($id);
		$this->title = (String)$title;
		$this->date = $date;
		$this->sent = $sent ? TRUE : FALSE;
		$this->designId = (String)$designId;
	}
	
	public function getId()
	{
		return $this->id;
	}
	
	public function getTitle()
	{
		return $this->title;
	}
	
	public function getDate()
	{
		return $this->date;
	}
	
	public function getSent()
	{
		return $this->sent;
	}
	
	public function getDesignId()
	{
		return $this->designId;
	}
	
	/**
	 * 
	 * Returns the Content-Array. If it is NULL, the data will be fetched by the Manager
	 * @return array
	 * 
	 */
	public function getContent()
	{
		if ($this->content == NULL)
		{
			$this->content = NewsletterManager::getInstance()->getContentByNewsletterId($this->id);
		}
		return $this->content;
	}
	
	public function setId($id)
	{
		$this->id = intval($id);
	}
	
	public function setTitle($title)
	{
		$this->title = (String)$title;
	}
	
	public function setDate(\DateTime $date)
	{
		$this->date = $date;
	}
	
	public function setSent($sent)
	{
		$this->sent = $sent ? TRUE : FALSE;
	}
	
	public function setDesignId($designId)
	{
		$this->designId = intval($designId);
	}
	
	/**
	 * 
	 * Sets the Content-Array
	 * @param array $content
	 * 
	 */
	public function setContent(Array $content)
	{
		$this->content = $content;
	}
	
}
